package com.itheima.test;

import java.util.ArrayList;
import java.util.Scanner;

public class ArrayListDemo04 {
    public static void main(String[] args) {
        // 1.定以集合
        ArrayList<Student> list = new ArrayList<>();

        // 2.键盘录入
        Scanner scanner = new Scanner(System.in);

        // 3.录入三个学生对象信息

        for (int i = 0; i < 3; i++) {
            Student student = new Student();

            System.out.println("请输入姓名:");
            String name = scanner.next();
            System.out.println("请输入年龄:");
            int age = scanner.nextInt();

            student.setName(name);
            student.setAge(age);

            list.add(student);

        }
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i).getName() +", "+ list.get(i).getAge());
        }

    }
}
